<html>
<head>
<TITLE>Internal System</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../css/style.css" type=text/css rel=stylesheet>
<script language="javascript" src="../js/Validation.js" type="text/JavaScript"></script>
<script language="javascript" src="../js/request.js" type="text/JavaScript"></script>
<script language="JavaScript" src="../js/calender.js" type="text/JavaScript"></script>

{literal}
<SCRIPT language=JavaScript>
	
	function add(advertiserId, merId, linkId)
	{
		var catId = document.getElementById("catId_" + linkId).value;
		
		var params = {'action':'add', 'searchType':'advertiserId', 'catId':catId, 'keyword':advertiserId, 'merId':merId, 'linkId':linkId};
		
//		alert("linkId id: " + linkId);
		
		request('', params, 'get');
	}
	
	function recommend(advertiserId, linkId, couponId, isRecommend)
	{
		var params = {'action':'recommend', 'searchType':'advertiserId', 'keyword':advertiserId, 'linkId':linkId, 'couponId':couponId, 'isRecommend':isRecommend};
		
//		alert("coupon id: " + couponId);
		
		request('', params, 'get');
	}
</script>
{/literal}

</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="1100" cellspacing="1" cellpadding="4">
<form name="form1" method="get" action="">
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#E9EDED';" onMouseOut="this.style.backgroundColor='#FFFFFF'"> 
    <td colspan="9" align="left">&nbsp;&nbsp;
    	Keyword : 
	    <input name="keyword" type="text" id="keyword" value="{$keyword}" size="60" maxlength="60" style="height:22px; margin-bottom:2px;"> 
	    
		Min create Date:    
	    <input name="createDateMin" type="text" id="createDateMin" value="{$createDateMin}" size="20" maxlength="20" onKeyDown="SelectDate(this,'yyyy-MM-dd')" onFocus="SelectDate(this,'yyyy-MM-dd')">
	    
	    <select name="searchType" style="height:22px; margin-top:0px;">
	  		{html_options options=$arrSearchType selected=$searchTypeS}
		</select>
		
	    <input type="submit" name="SubmitGanApi" value="SyncGan">
	    	 | 
	    <input type="submit" name="displayDBgan" value="DisplayDBgan">
	    
	    <input type="submit" name="addAdvertiser" value="Add Advertiser">
	    
	    <input name="menuGid" type="hidden" id="menuGid" value="{$menuGid}">
	    <input name="menuid" type="hidden" id="menuid" value="{$menuid}">
	
    </td>
  </tr>
 </form>
 
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#E9EDED';" onMouseOut="this.style.backgroundColor='#E9EDED'"> 
    <td colspan="9" height=30>&nbsp; Matched merchant[ {$oMer->getId()} ]: {$oMer->getName()} ({$linkCount}) &nbsp;&nbsp;&nbsp;
	</td>
  </tr>
  
  <tr bgcolor="#E4E4E4"> 
    <td width="100">Link Id</td>
    <td width="60">Adver Id</td>
    <td width="200">Category</td>
    <td width="200">Name</td>
    <td width="100">Code</td>
    <td width="150">Date Range</td>
    <td width="60">Matched</td>
   	<td width="230">Action | <b><a href="#">Add All</a></b></td>
  </tr>
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#E9EDED';" onMouseOut="this.style.backgroundColor='#FFFFFF'"> 
    <td colspan="7" align="center"><font color="#FF0000">{$error_message}</font></td>
  </tr>
 
  {foreach item=link from=$ganLinks}
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#E9EDED';" onMouseOut="this.style.backgroundColor='#FFFFFF'"> 
    <td>{$link->linkId}</td>
    <td><a href="">{$link->advertiserId}</a></td>
    <td><select id="catId_{$link->linkId}" style="height:22px; margin-top:0px;">
	  		{html_options options=$arrCategories selected={$link->r_catId}}
		</select>
	</td>
    <td title="{$link->name}" title="{$link->name}">&nbsp;{$link->name|truncate:30:"..."}</td>
    <td>{$link->soPromoCodes}</td>
    <td>{$link->startDate|date_format:'%Y-%m-%d'} ~ {$link->endDate|date_format:'%Y-%m-%d'}</td>
    <td>
    	{if $link->r_couponId > 0}
    		{if $link->r_matched == 1}
    			<a href="" title="{$link->r_couponId}">tracking url</a>
    		{else if $link->r_matched == 2}
    			<a href="" title="{$link->r_couponId}">Id key</a>
    		{else}

    		{/if}
    	{else}
    		n/a
    	{/if}
    </td>
    
    <td>
    	{if $link->r_couponId > 0}
    		{if $link->r_recommend > 0}
    			<a href="#" onclick="recommend('{$advertiserId}', '{$link->linkId}', '{$link->r_couponId}', '0');">Recommended</a>&nbsp;&nbsp;|
    		{else}
    			<a href="#" onclick="recommend('{$advertiserId}', '{$link->linkId}', '{$link->r_couponId}', '1');">Recommend</a>&nbsp;&nbsp;|
    		{/if}
    	{else}
    		
    	{/if}
    	
    	{if $keyword != '' && $oMer->getId() > 0}
    			<a href="#" onclick="add('{$advertiserId}', '{$oMer->getId()}', '{$link->linkId}');">Add</a>&nbsp;&nbsp;
    	{/if}
    		
	    {section name=opItem loop=$arrOperateInfo}
	   		{if $smarty.section.opItem.index != 0}
	    		&nbsp;&nbsp;|&nbsp;&nbsp;
	   	    {/if}
	
	   		<a href="{$selfFileName}_{$arrOperateInfo[opItem].name}.php?menuGid={$menuGid}&menuid={$menuid}&id={$link->id}" 
	   			onClick="return validDefault.isConfirmOperate('{$arrOperateInfo[opItem].name}')">{$arrOperateInfo[opItem].viewName}</a>
	   	{/section}
    </td>
  </tr>
  {/foreach}
</table>
<table width="100%" cellspacing="0" cellpadding="4">
  <tr> 
    <td align="left" width="60%">{$PAGE_BAR}</td>
    <td align="right" width="40%"></td>
  </tr>
</table>
</body>
</html>